package com.huike.web.controller.report;


import com.huike.report.domain.vo.MyIndexVo;
import com.huike.report.domain.vo.ReportVo;
import com.huike.common.utils.SecurityUtils;
import com.huike.report.domain.vo.IndexVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;


    /**
     * 首页--基础数据统计
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime,endCreateTime));
    }

    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo() {
        ReportVo reportVo =  reportService.getTodayInfo();
        return AjaxResult.success(reportVo);
    }

    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(String beginCreateTime, String endCreateTime) {

        //System.out.println("线索创建时间"+beginCreateTime);
        //System.out.println("线索结束时间"+endCreateTime);
        String username = SecurityUtils.getUsername();
        MyIndexVo indexVo = new MyIndexVo();
        indexVo.setTofollowedCluesNum(reportService.getTofollowedCluesNum(beginCreateTime,endCreateTime,username));
        indexVo.setTofollowedBusinessNum(reportService.getTofollowedBusinessNum(beginCreateTime,endCreateTime,username));
        indexVo.setToallocatedCluesNum(reportService.getToallocatedCluesNum(beginCreateTime,endCreateTime));
        indexVo.setToallocatedBusinessNum(reportService.getToallocatedBusinessNum(beginCreateTime,endCreateTime,username));
        return AjaxResult.success(indexVo);
    }
}